<?php

namespace app\controller\web;

use app\service\NotesInfoService;
use app\service\VersionInfoService;
use app\validate\NotesInfoValidate;
use app\validate\PageValidate;
use share\utils\Helper;

class NotesInfoController extends WebBaseController{

    public function initValidate(){        
        $this->validate = new NotesInfoValidate();
    }

    /**
     * 删除APP版本
     */
    public function del_action(){
        $input = $this->check();
        $data = NotesInfoService::del($input['id']);
        return self::ok($data);
    }

    /**
     * 列表 搜索
     */
    public function list_action(){
        $page = $this->check('pageInfo',null,(new PageValidate()));
        $input = $this->check();       
        $data = NotesInfoService::getListInfo($input,$page);
        $data = Helper::arrayListReplaceKey($data,[
            'contact_way' => 'contactWay',
            'contact_type' => 'contactType',
            'app_version' => 'appVersion',
        ]);
        $total = NotesInfoService::getListCountInfo($input);
        return self::ok(self::formatPageData($page,$total,$data));
    }

}